<include file="Common:layout" />
<style type="text/css">
    .out_put_btn {
        display: block;
        font-size: 12px;
        color: #0ba4da;
        background-color: #FFFFFF;
        padding: 4px 7px;
        border: solid 1px #3aa8cf;
        border-radius: 4px;
        cursor: pointer;
    }
    .out_put_btn:hover {
        background-color: #e6fcff;
    }
</style>
<body style="background-color: #FFF; overflow: auto;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>订单列表</h3>
            </div>
        </div>
    </div>

    <bDi class="flexigrid" >
        <form action="" class="navbar-form form-inline" method="get">
            <div class="mDiv">
                <input type="hidden" name="m" value="admin"/>
                <input type="hidden" name="c" value="order"/>
                <input type="hidden" name="a" value="index"/>
                <div class="sDiv">
                    <div class="sDiv2">
                        <input type="text" size="20" name="user_name" placeholder="收货人用户名或手机" value="{$u_name}">
                        <input type="text" size="14" name="user_phone" placeholder="下单人用户名" value="{$u_phone}">
                        <input type="text" size="14" name="start_time" id="start_time" placeholder="下单开始时间" value="{$start_time}" readonly>
                        <input type="text" size="14" name="end_time" id="end_time" placeholder="下单结束时间" value="{$end_time}" readonly>
                        <input type="text" size="14" name="order_id" placeholder="填写订单编号" value="{$orderId}">
                        <input type="text" size="14" id="shop_name" name="shop_name" placeholder="搜索店铺名" value="{$shop_name}">
                        <select  class="select" name="shop_id" id="shop_id">
                            <option value="">请选择店铺名</option>
                            <volist name="shops" id="shop">
                                <option value="{$shop['id']}">{$shop['shop_name']}</option>
                            </volist>
                        </select>

                        <select class="select" name="is_pay" size="1">
                            <option value="-2">支付状态</option>
                            <foreach name="pay_status" item="pay" key="k">
                                <if condition="$k eq $x_pay">
                                    <option value="{$k}" selected="selected">{$pay}</option>
                                    <else />
                                    <option value="{$k}">{$pay}</option>
                                </if>
                            </foreach>
                        </select>

                        <select class="select" name="status" size="1">
                            <option value="-2">订单状态</option>
                            <foreach name="order_status" item="status" key="k">
                                <if condition="$k eq $x_status">
                                    <option value="{$k}" selected="selected">{$status}</option>
                                    <else />
                                    <option value="{$k}">{$status}</option>
                                </if>
                            </foreach>
                        </select>


                        <select class="select" name="is_deliver" size="1">
                            <option value="-2">发货状态</option>
                            <foreach name="deliver_status" item="deliver" key="k">
                                <if condition="$k eq $x_deliver">
                                    <option value="{$k}" selected="selected">{$deliver}</option>
                                    <else />
                                    <option value="{$k}">{$deliver}</option>
                                </if>
                            </foreach>
                        </select>
                        <input type="submit" class="btn" value="搜索" name="btn"/>
                    </div>
                </div>
            </div>
            <div class="hDiv">
                <div class="hDivBox">
                    <table cellspacing="0" cellpadding="0">
                        <thead>
                        <tr>
                            <th align="center" abbr="article_title" axis="col6">
                                <div style="text-align: center; width:50px;" class="">ID</div>
                            </th>
                            <th align="center" abbr="article_title" axis="col3" class="">
                                <div style="text-align: center; width: 100px;" class="">订单编号</div>
                            </th>
                            <th align="center" abbr="ac_id" axis="col4" class="">
                                <div style="text-align: center; width: 80px;" class="">下单人</div>
                            </th>
                            <th align="center" abbr="ac_id" axis="col4" class="">
                                <div style="text-align: center; width: 120px;" class="">收货人</div>
                            </th>
                            <th align="center" abbr="article_show" axis="col5" class="">
                                <div style="text-align: center; width: 60px;" class="">总金额</div>
                            </th>
                            <th align="center" abbr="article_time" axis="col6" class="">
                                <div style="text-align: center; width: 50px;" class="">支付状态</div>
                            </th>
                            <th align="center" abbr="article_time" axis="col6" class="">
                                <div style="text-align: center; width: 80px;" class="">发货状态</div>
                            </th>
                            <th align="center" abbr="article_time" axis="col6" class="">
                                <div style="text-align: center; width: 80px;" class="">店铺名称</div>
                            </th>
                            <th align="center" abbr="article_time" axis="col6" class="">
                                <div style="text-align: center; width: 50px;" class="">订单状态</div>
                            </th>
                            <th align="center" abbr="article_time" axis="col6" class="">
                                <div style="text-align: center; width: 60px;" class="">运费</div>
                            </th>
                            <th align="center" abbr="article_time" axis="col6" class="">
                                <div style="text-align: center; width: 130px;" class="">下单时间</div>
                            </th>
                            <th align="center" abbr="article_title" axis="col6">
                                <div style="text-align: center; width:180px;" class="">操作</div>
                            </th>
                            <th style="width:100%" axis="col7">
                                <div></div>
                            </th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
            <div class="tDiv">
                <div class="tDiv2">
                    <div class="fbutton">
                        <button type="submit" name="export" value="1" class="out_put_btn">
                            <i class="fa fa-download"></i>导出订单</button>
                    </div>
                </div>
                <div style="clear:both"></div>
            </div>
            <div class="bDiv" style="height: auto;">
                <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                    <table>
                        <tbody>
                        <volist name="orders" id="order" key="k" >
                            <tr>
                                <td align="center" axis="col0">
                                    <div style="width: 50px;">{$order.id}</div>
                                </td>
                                <td align="center" class="">
                                    <div style="text-align: left; width: 100px;">{$order['order_id']}</div>
                                </td>
                                <td align="center" class="">
                                    <div style="text-align: left; width: 80px;">{$order['agent_name']}</div>
                                </td>
                                <td align="center" class="">
                                    <div style="text-align: left; width: 120px;">
                                        {$order['consignee']}: {$order['phone']}
                                    </div>
                                </td>
                                <td align="center" class="">
                                    <div style="text-align: center; width: 60px;">
                                        {$order['price']}
                                    </div>
                                </td>
                                <td align="center" class="">
                                    <div style="text-align: center; width: 50px;">
                                        <if condition="$order['is_pay'] eq -1">
                                            <span style="color: red;">未付款</span>
                                            <else />
                                            <span style="color: green;">已付款</span>
                                        </if>
                                    </div>
                                </td>
                                <td align="center">
                                    <div style="text-align: center; width: 80px;">
                                        <if condition="$order['is_deliver'] eq -1">
                                            <if condition="($order['is_pay'] eq 1 AND $order['is_top'] eq 1) OR ($order['is_pay'] eq 1 AND $order['is_platform'] eq 1) OR ($order['is_pay'] eq 1 AND $order['is_no_agent'] eq 1)">
                                                <span style="color: red;">待平台发货</span>
                                                <elseif condition="$order['is_agree'] neq -1"/>
                                                <span style="color: #ccc;">未发货</span>
                                                <elseif condition="$order['is_agree'] eq -1"/>
                                                <span style="color: firebrick;">未发货(董事不通过)</span>
                                            </if>
                                            <else />
                                            <span style="color: green">已发货</span>
                                        </if>
                                    </div>
                                </td>
                                <td align="center" class="">
                                    <div style="text-align: center; width: 80px;">
                                        {$order['shop_name']}
                                    </div>
                                </td>
                                <td align="center">
                                    <div style="text-align: center; width: 50px;">
                                        <switch name="order['status']">
                                            <case value="-1">
                                                <span style="color: red;">已取消</span>
                                            </case>
                                            <case value="1">
                                                <span style="color: #9c9c9c">待确认</span>
                                            </case>
                                            <case value="2">
                                                <span style="color: chartreuse;">退款订单</span>
                                            </case>
                                            <case value="3">
                                                <span style="color: green;">交易成功</span>
                                            </case>
                                            <default />
                                            <span style="color:blue;">进行中</span>
                                        </switch>
                                    </div>
                                </td>
                                <td align="center">
                                    <div style="text-align: center; width: 60px;">
                                        {$order['freight_price']}元
                                    </div>
                                </td>
                                <td align="center">
                                    <div style="text-align: center; width: 130px;">
                                        {$order['time']|date="Y-m-d H:i:s",###}
                                    </div>
                                </td>
                                <td align="left">
                                    <div style="text-align: left; width: 180px;">
                                        <a class="btn blue" href="{:U('Order/detail', array('id'=>$order['id']))}" ><i class="fa fa-search"></i>查看</a>
                                    </div>
                                </td>
                                <td align="" class="" style="   width: 100%;">
                                    <div>&nbsp;</div>
                                </td>
                            </tr>
                        </volist>
                        </tbody>
                    </table>
                </div>
                <!--分页位置-->
                {$page}
            </div>
        </form>
    </bDi>
</div>
<script type="text/javascript" src="__PUBLIC__/usr/js/layer/laydate/laydate.js"></script>
<script type="text/javascript">
    $(function() {

        //选择不同的店铺
        $('#shop_id').change(function() {
            var name = $(this).find("option:selected").text();
            $('#shop_name').val(name);
        });


        //日历插件
        $('#start_time').layDate();
        $('#end_time').layDate();

        $("#shop_name").keyup(function(){
            $aName = $(this).val();
            if($aName != ''){
                getAgentName();
            }else{
                return false;
            }
        });

        $("#shop_name").change(function(){
            $aName = $(this).val();
            if($aName != ''){
                getAgentName();
            }else{
                return false;
            }
        });
    });
    function getAgentName()
    {
        $.ajax({
            url: "{:U('Order/searchShopName')}",
            type: "post",
            data: {aName : $aName},
            success: function (data) {
                var options = '<option value="">请选择店铺名</option>';
                if (data) {
                    $.each(data, function(k, v){
                       options += '<option value="'+ v.id +'">'+ v.shop_name +'</option>';
                    });
                }
                $("#shop_id").html(options);
            }
        });
    }
</script>
